#include"ProcessBar.h"
#include<string.h>
#include<unistd.h>
const char *lable = "|/-\\";

char Bar[NUM];
#define GREEN "\033[0;32;32m"
#define NONE "\033[m"

void ProcessBar(int rate)
{
  if(rate < 0 || rate > 100)
    return;
  int len = strlen(lable);
  printf(GREEN"[%-100s]"NONE"[%d%%][%c]\r", Bar, rate, lable[rate%len]);
  fflush(stdout);
   Bar[rate++] = BODY;
  if(rate < 100) 
    Bar[rate] = RIGHT;
}

void initbar()
{
    memset(Bar, '\0', sizeof(Bar));
}


/*void ProcessBar()
{
  char Bar[NUM];
  memset(Bar,'\0',sizeof(Bar));
  int cnt =0;
  int len = strlen(lable);
  while(cnt <= 100)
  {
    printf("[%-100s][%d%%][%c]\r",Bar,cnt,lable[cnt%len]);
    Bar[cnt++]=STYLE;
    Bar[cnt]='>';
    fflush(stdout);
    usleep(100000);

  }
  printf("\n");
  //printf("Hello Linux\n");
}*/ 
